<?php
namespace Forms\Render;

use Pinenut\Form\RenderAction;

class FormAction extends RenderAction
{
	public function run()
	{
		$params = $this->request->params();
		$htmlOptions = '';
		
		$params['htmlOptions']['class'] = isset($params['htmlOptions']['class'])
			?$params['htmlOptions']['class'].' active-form':
			'active-form';
		
		if (!empty($params['htmlOptions'])) {
			foreach($params['htmlOptions'] as $name => $value) {
				$htmlOptions .= ' ' . $name . '="' . $value . '"';
			}
		}

		$elementValue = '';
		if (!empty($params['value'])) {
			$elementValue = $params['value'];
		}

		$this->response->value = $elementValue;
		$this->response->params = $params;
		$this->response->htmlOptions = $htmlOptions;
	}
}